package com.sxdz.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.quartz.CronTriggerFactoryBean
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean

/**
 * Created by lzw on 2016/8/24.
 */

@Configuration
class QuartzConfig {

    @Bean
    SchedulerFactoryBean schedulerFactoryBean() {
        new SchedulerFactoryBean(
                triggers: [cronTriggerFactoryBean().getObject()]
        )
    }

    @Bean
    CronTriggerFactoryBean cronTriggerFactoryBean() {
        new CronTriggerFactoryBean(
                jobDetail: jobDetailBean().getObject(),
                cronExpression: "0 1 8 * * ?"
        )
    }

    @Bean
    MethodInvokingJobDetailFactoryBean jobDetailBean() {
        new MethodInvokingJobDetailFactoryBean(
                targetBeanName: "reconciliation",
                targetMethod: "main"
        )
    }

}
